//
//  TipsView.m
//  Cooking
//
//  Created by dllo on 15/8/24.
//  Copyright (c) 2015年 ZP.Y. All rights reserved.
//

#import "TipsView.h"
#import "AppMacro.h"
#import "TipsFirstPageModel.h"

@interface TipsView ()

@property (retain, nonatomic) UIImageView *view;

@end

@implementation TipsView

- (void)dealloc {
    [_titleLabel release];
    [_introduceLabel release];
    [_rightView release];
    [_view release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.titleLabel = [[UILabel alloc] init];
//    _titleLabel.backgroundColor = [UIColor grayColor];
    
    if ([UIScreen mainScreen].bounds.size.width == 320) {
        _titleLabel.font = [UIFont systemFontOfSize:14];
    } else if ([UIScreen mainScreen].bounds.size.width == 375){
        _titleLabel.font = [UIFont systemFontOfSize:17];
    }
    
    [self addSubview:_titleLabel];
    [_titleLabel release];
    
    self.introduceLabel = [[UILabel alloc] init];
//    _introduceLabel.backgroundColor = [UIColor grayColor];
    _introduceLabel.numberOfLines = 2;
    _introduceLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:_introduceLabel];
    [_introduceLabel release];
    
    self.rightView = [[UIImageView alloc] init];
//    _rightView.backgroundColor = [UIColor grayColor];
    _rightView.layer.cornerRadius = 5;
    _rightView.layer.masksToBounds = YES;
    [self addSubview:_rightView];
    [_rightView release];
    
    self.view = [[UIImageView alloc] init];
//    view.backgroundColor = [UIColor grayColor];
    _view.image = [self imageWithName:@"iconfont-biaoti" imageType:@"png"];
    [self addSubview:_view];
    [_view release];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    if ([UIScreen mainScreen].bounds.size.height == 667) {
        _view.frame = CGRectMake(8, 27, 20, 20);
        _titleLabel.frame = CGRectMake(28, 20, WIDTH / 2 - 10, 35);
        _introduceLabel.frame = CGRectMake(15, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15, WIDTH / 2 - 10, 40);
        _rightView.frame = CGRectMake(_titleLabel.frame.origin.x + _titleLabel.frame.size.width, 10, WIDTH / 2 - 25, self.frame.size.height - 20);

    } else if ([UIScreen mainScreen].bounds.size.height == 568) {
        _view.frame = CGRectMake(8, 18, 20, 20);
        _titleLabel.frame = CGRectMake(28, 10, WIDTH / 2 - 10, 35);
        _introduceLabel.frame = CGRectMake(15, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15, WIDTH / 2 - 10, 40);
        _rightView.frame = CGRectMake(_titleLabel.frame.origin.x + _titleLabel.frame.size.width, 10, WIDTH / 2 - 25, self.frame.size.height - 20);

    } else if ([UIScreen mainScreen].bounds.size.height == 736) {
        _view.frame = CGRectMake(8, 27, 20, 20);
        _titleLabel.frame = CGRectMake(28, 20, WIDTH / 2 - 10, 35);
        _introduceLabel.frame = CGRectMake(15, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15, WIDTH / 2 - 10, 40);
        _rightView.frame = CGRectMake(_titleLabel.frame.origin.x + _titleLabel.frame.size.width, 10, WIDTH / 2 - 25, self.frame.size.height - 20);

    } else {
        _view.frame = CGRectMake(8, 18, 20, 20);
        _titleLabel.frame = CGRectMake(28, 10, WIDTH / 2 - 10, 35);
        _introduceLabel.frame = CGRectMake(15, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15, WIDTH / 2 - 10, 40);
        _rightView.frame = CGRectMake(_titleLabel.frame.origin.x + _titleLabel.frame.size.width, 10, WIDTH / 2 - 25, self.frame.size.height - 20);
    }


}

- (UIImage *)imageWithName:(NSString *)imageName imageType:(NSString *)imageType {
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName ofType:imageType];
    UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
    return image;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
